/*
 * FunctionAnalyzer.h
 *
 *  Created on: 27 мая 2022 г.
 *      Author: nikita
 */

#ifndef SRC_FUNCTIONANALYZER_V_H_
#define SRC_FUNCTIONANALYZER_V_H_

#include "../../Math_stuff/MVariable.h"
#include "../../Technical/RuntimeErrorClass.h"
#include "../../Technical/Logger.h"
#include "../../STL_includes.h"

#include "../../Typedefs.h"
#include "../../Enums.h"

#include "../Counter.h"


namespace STC_calc {

class MathFunction;
class MathObject;

/*
* The FunctionAnalyzer class transform a string
* after the Functional Preprocessor to the MathFunction.
*/
class FunctionAnalyzer {
public:

	static const std::map<std::string, int> priority_function;
	static const std::map<std::string, std::string> function_dictionary;

private:
	FunctionAnalyzer();
	~FunctionAnalyzer();

	static const std::map<std::string, Enums::brackets_types> open_brackets;
	static const std::map<std::string, Enums::brackets_types> close_brackets;
	static const string_vector base_functions;
    static const string_vector counter_functions;

    static bool is_open_bracket(const std::string& s);
	static bool has_base(const std::string& func_name);
	static std::string base_define(const std::string& str, const std::string& func);
	static void remove_base_garbage(std::string& str);
	static int find_without_brackets(const std::string& str, const std::string& substr);

	static bool is_it_close_bracket(const std::string& s, const Enums::brackets_types type);
	static Enums::brackets_types define_open_bracket_type(const std::string& s);

	static std::string simplify_string(const std::string str);

public:

	static void remove_brackets(std::string& str);//It removes in-brackets substring

	static std::string define_name_function(const std::string& simp_str);//Defines type functuin
	static string_vector define_func_args(const std::string& args, const std::string& func);

	friend class FunctionAnalyzer_test;
};

} /* namespace STC_calc */

#endif /* SRC_FUNCTIONANALYZER_V_H_ */
